<template>
  <div>
    <!-- 缩放放大 按钮-->
    <div class="collapse-btn" @click="collapseChange()">
      <i class="el-icon-menu"></i>
    </div>
    <!-- 文字 -->
    <div class="logo">music后台管理</div>

    <!-- 右边部分 -->
    <div class="header-right">

      
      <!-- 头像 -->
      <div class="user-page">
        <img src="@/assets/img/user.jpg">
      </div>
      
      <!-- 下拉框 -->
      <el-dropdown class="user-name" trigger="click" @command='handleCommand'>
        <span class="el-dropdown-link">
          {{ username }}
          <i class="el-icon-caret-bottom"></i>
        </span>
        <el-dropdown-menu slot="dropdown">
          <el-dropdown-item command="logout">退出登录</el-dropdown-item>
        </el-dropdown-menu>
      </el-dropdown>

    </div>
  </div>
</template>

<script>


export default {
  data() {
    return {
      collapse: false,
      fullscreen: false
    }
  },
  computed: {
    username() {
      return localStorage.getItem('username')
    }
  },
  methods: {
    handleCommand(command){
      if(command === 'logout'){
        localStorage.removeItem('username');
        this.$router.push('/')
      }
    }
  }
}
</script>

<style scoped>
.collapse-btn {
  float: left;
  padding: 0 21px;
  cursor: pointer;
  line-height: 70px;
}

.logo {

  float: left;
  line-height: 70px;
}

.header-right {
  float: right;
  padding-right: 50px;
  display: flex;
  height: 70px;
  align-items: center;
}

.btn-fullScreen {
  transform: rotate(45deg);
  margin-right: 5px;
  font-size: 24px;
}

.user-page {
  margin-left: 20px;
}

.user-page img {
  display: block;
  width: 40px;
  height: 40px;
  border-radius: 50%;
}
.el-dropdown-link{
  margin-left: 10px;
  color: #ffffff;
  cursor: pointer;
}
</style>